import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import ProblemsVue from '@/views/Problems.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path:'/',
    redirect: "/home/index"

  },
  {
    path: '/home',
    name: 'home',
    meta: {
      keepAlive: true, //添加这个作为标志符，表明该页面需要保留状态
    },
    component: HomeView,
    children:[
      {
        path:'index',
        name:'index',
        component:()=>import ('@/components/Main/MainContainer.vue')
      },
        {
          path:'study',
          name:'study',
          component:()=>import ('@/views/study.vue')
        },
        {
          path:'homework',
          name:'homework',
          component:()=>import('@/views/Homework.vue')
        },
        {
          path:'itemBank',
          name:'itemBank',
          component:()=>import('@/views/itemBank.vue')
        }
    ]
  },
  {
    path: '/problem',
    name: 'problem',
    component: ProblemsVue
  },
  {
    path:'/login',
    name:'login',
    component:()=>import ('@/views/Login.vue')
  }
 
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
